﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/WithoutPermBasic.Master" AutoEventWireup="true" CodeBehind="PrintContract.aspx.cs" Inherits="PMS.UI.CM.PrintContract" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        //通过分析模块内部进入，传了ID
        var Id = com.get.Id;
        var contData = undefined;
        $(function () {

            //加载客户信息
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "/Logic/CM/ContractAjax.aspx?method=GetContractAndCustomerInfoByID",
                data: { "id": Id },
                asyn: false,
                success: function (data) {
                    contData = data;
                    //加载页头表格
                    $("#Code").html(data.Code);
                    $("#CustomerNameA").html(data.ComName);
                    $("#Address").html(data.Address);
                    $("#SignDate").html(data.SignDate);
                    //加载页尾表格
                    $("#CustomerNameB").html(data.ComName);
                    $("#ComAddress").html(data.ComAddress);
                    $("#Bank").html(data.Bank);
                    $("#BankAccount").html(data.BankAccount);
                    $("#TaxpayerID").html(data.TaxpayerID);
                    $("#Phone").html(data.Phone);
                    $("#Fax").html(data.Fax);

                    JsBarcode("#imgBarcode", data.Code, {
                        width: 2.6,//设置条之间的宽度
                        height: 64,//高度
                        displayValue: true,//是否在条形码下方显示文字
                    });

                    //加载产品信息
                    $.ajax({
                        type: "POST",
                        dataType: "json",
                        url: "/Logic/CM/QuotationAjax.aspx?method=GetAllProductDetailForContractPrint",
                        data: { "contID": Id },
                        asyn: false,
                        success: function (pData) {
                            address = pData.address;
                            $("#QuotationAddress").html(address.substring(0, address.length - 1) + "。");
                            //console.log(pData.listAll)
                            LoadDetailData(pData.listAll);
                        }
                    });
                }
            });

            $("#btnPrint").click(function () {
                //提货日期
                var deadLine = $("#deadLineInput").val();
                $("#deadLine").html(deadLine);
                $("#deadLine").show();
                $("#deadLineInput").hide();

                // 结算方式
                var payWay = $("#payWayInput").val();
                $("#payWay").html(payWay);
                $("#payWay").show();
                $("#payWayInput").hide();

                $("#divPrint").print({
                    globalStyles: true,//是否包含父文档的样式，默认为true
                    mediaPrint: false,//是否包含media='print'的链接标签。会被globalStyles选项覆盖，默认为false
                    stylesheet: null,//外部样式表的URL地址，默认为null
                    noPrintSelector: ".no-print",//不想打印的元素的jQuery选择器，默认为".no-print"
                    iframe: true,//是否使用一个iframe来替代打印表单的弹出窗口，true为在本页面进行打印，false就是说新开一个页面打印，默认为true
                    append: null,//将内容添加到打印内容的后面
                    prepend: null,//将内容添加到打印内容的前面，可以用来作为要打印内容
                    deferred:
                 $.Deferred(

                        )//回调函数
                });
            });
        })

        function LoadDetailData(data) {
            var content = "";
            var price = 0;
            for (var i = 0; i < data.length; i++) {
                content += "<tr>";
                content += "<td style='font-size:16px; text-align:center'>";
                content += i + 1;
                content += "</td>";

                content += "<td style='font-size:16px'>";
                content += data[i].ProductName;
                content += "</td>";

                content += "<td style='font-size:16px'>";
                content += com.ConvertLowerAndUper(data[i].TechParams,data[i].IsPureGas);
                content += "</td>";

                content += "<td style='font-size:16px; text-align:center'>";
                content += data[i].BottleVolume;
                content += "</td>";

                //气体信息
                content += "<td style='font-size:16px; text-align:center'>";
                content += data[i].OrderCount;
                content += "</td>";

                content += "<td style='font-size:16px; text-align:center'>";
                content += data[i].SinglePrice;
                content += "</td>";

                //钢品信息
                content += "<td style='font-size:16px; text-align:center'>";
                content += data[i].BottleCount;
                content += "</td>";

                content += "<td style='font-size:16px; text-align:center'>";
                content += data[i].BottlePrice;
                content += "</td>";

                content += "<td style='font-size:16px; text-align:center'>";
                content += data[i].TotalPrice;
                content += "</td>";

                content += "</tr>";
                price += data[i].TotalPrice;
            }
            content += "<tr>";
            content += "<td style='font-size:16px;text-align:center' rowspan='2' >备注：</td>"
            content += "<td style='font-size:16px' colspan='2' rowspan='2'>" + contData.Note + "</td>"
            content += "<td style='font-size:16px;text-align:center' colspan='3' >合同金额（小写）：</td>"
            content += "<td style='font-size:16px;text-align:center' colspan='3'>" + price + "</td>"
            content += "</tr>";
            content += "<tr>";
            content += "<td style='font-size:16px;text-align:center' colspan='3'>合同金额（大写）：</td>"
            content += "<td style='font-size:16px;text-align:center' colspan='3' >" + moneyToChi(price) + "</td>"
            content += "</tr>";
            $("#detailBody").html("");
            $("#detailBody").append(content);
        }

        //金额转大写
        function moneyToChi(num) {
            if (isNaN(num)) return "";
            var strPrefix = "";
            if (num < 0) strPrefix = "(负)";
            num = Math.abs(num);
            if (num >= 1000000000000) return "无效数值！";
            var strOutput = "";
            var strUnit = '仟佰拾亿仟佰拾万仟佰拾元角分';
            var strCapDgt = '零壹贰叁肆伍陆柒捌玖';
            num += "00";
            var intPos = num.indexOf('.');
            if (intPos >= 0) {
                num = num.substring(0, intPos) + num.substr(intPos + 1, 2);
            }
            strUnit = strUnit.substr(strUnit.length - num.length);
            for (var i = 0; i < num.length; i++) {
                strOutput += strCapDgt.substr(num.substr(i, 1), 1) + strUnit.substr(i, 1);
            }
            return strPrefix + strOutput.replace(/零角零分$/, '整').replace(/零[仟佰拾]/g, '零').replace(/零{2,}/g, '零').replace(/零([亿|万])/g, '$1').replace(/零+元/, '元').replace(/亿零{0,3}万/, '亿').replace(/^元/, "零元");
        }

    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceToorbar" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <input type="button" id="btnPrint" value="打印" style="height: 28px; width: 100px" />
    <div id="divPrint" style="margin-top: 20px; width: 960px">
        <div id="divBZWZ" style="margin-left: 20px; text-align: left; float: left">
            <label style="font-size: 64px; font-weight: bold; font-family: Simsun; margin-left: 20px; float: left">工业品买卖合同</label>
        </div>
        <div>
            <img id="imgBarcode" style="float: right; margin-right: 30px;" src="#" />
        </div>
        <div class="clear" style="height: 10px"></div>
        <table id="headTab" style="word-wrap: break-word; word-break: break-all;">
            <tr>
                <td style="width: 100px; font-size: 16px; font-family: Simsun; text-align: center">合同编号：</td>
                <td style="width: 600px; font-size: 16px; text-align: center" colspan="3"><span style="font-size: 20px; font-family: Times New Roman;" id="Code"></span></td>
            </tr>
            <tbody>
                <tr>
                    <td style="width: 100px; font-size: 16px; font-family: Simsun; text-align: center">供方：</td>
                    <td style="width: 300px; font-size: 16px; font-family: Simsun; text-align: center">杭州新世纪混合气体有限公司</td>
                    <td style="width: 100px; font-size: 16px; font-family: Simsun; text-align: center">签订地点：</td>
                    <td style="width: 300px; text-align: center"><span style="font-size: 16px; font-family: Simsun;" id="Address"></span></td>
                </tr>
                <tr>
                    <td style="width: 100px; font-size: 16px; font-family: Simsun; text-align: center">需方：</td>
                    <td style="width: 300px; font-size: 16px; text-align: center"><span style="font-size: 16px; font-family: Simsun;" id="CustomerNameA"></span></td>
                    <td style="width: 100px; font-size: 16px; font-family: Simsun; text-align: center">签订时间：</td>
                    <td style="width: 300px; font-size: 16px; text-align: center"><span style="font-size: 16px; font-family: 'Times New Roman';" id="SignDate"></span></td>
                </tr>
            </tbody>
        </table>
        <span style="font-size: 20px; font-family: Simsun; margin-left: 40px">第一条：样气、数量、价款。</span><br />
        <table id="tbDetail" style="word-wrap: break-word; word-break: break-all;">
            <tr>
                <td style="width: 60px; font-size: 20px; font-family: Simsun; text-align: center">序号</td>
                <td style="font-size: 20px; width: 200px; font-family: Simsun; text-align: center">产品名称</td>
                <td style="width: 240px; font-size: 20px; font-family: Simsun; text-align: center">产品详细参数</td>
                <td style="width: 60px; font-size: 20px; font-family: Simsun; text-align: center">规格/L</td>
                <td style="width: 80px; font-size: 20px; font-family: Simsun; text-align: center">数量/瓶</td>
                <td style="width: 80px; font-size: 20px; font-family: Simsun; text-align: center">单价/元</td>
                <td style="width: 80px; font-size: 20px; font-family: Simsun; text-align: center">钢品数量/瓶</td>
                <td style="width: 80px; font-size: 20px; font-family: Simsun; text-align: center">钢瓶单价/元</td>
                <td style="width: 80px; font-size: 20px; font-family: Simsun; text-align: center">小计/元</td>
            </tr>
            <tbody id="detailBody">
            </tbody>
        </table>
        <style type="text/css">
            table {
                border-collapse: collapse;
                border: 1px solid;
                margin-left: 40px;
                width: 880px;
            }

            td {
                border: 1px solid;
                font-size: 24px;
                font-family: Simsun,'Times New Roman';
                text-align: left;
            }

            #divPrint span {
                line-height: 26pt;
            }
        </style>

        <div style="margin-top: 0px; margin-left: 40px">
            <span style="font-size: 20px; font-family: Simsun;">第二条：交（提）货时间：<b><u style="font-size: 20px; font-family: Simsun;">收到订单全款后
                <label style="font-size: 20px; display: none; font-weight: bold; font-family: 'Times New Roman';" id="deadLine"></label>
                <input id="deadLineInput" style="font-family: SimSun; font-size: 20px; text-align: center; width: 20px" />
                个工作日发货。</u></b></span><br />
            <span style="font-size: 20px; font-family: Simsun;">第三条：质量标准：<b><u style="font-size: 20px; font-family: Simsun;">按质量标准验收。</u></b></span><br />
            <span style="font-size: 20px; font-family: Simsun;">第四条：交（提）货方式、地点：<u><span style="font-family: SimSun; font-size: 20px; font-weight: bold" id="QuotationAddress"></span></u></span><br />
            <span style="font-size: 20px; font-family: Simsun;">第五条：结算方式：<b><u style="font-size: 20px; font-family: Simsun,'Times New Roman';">
             <label style="font-size: 20px; display: none; font-weight: bold; font-family: 'SimSun','Times New Roman';" id="payWay"></label>
                <input id="payWayInput" style="font-family: SimSun; font-size: 20px; text-align: center; width: 700px" value="需方以银行回款或全额现金支付方式付清全款，供方开具13%增值税发票或普票。" />
            </u></b></span>
            <br />
            <span style="font-size: 20px; font-family: Simsun;">第六条：随机的必备品、配件、工具数量及供应方法：<b><u style="font-size: 20px; font-family: Simsun;">标准物质证书。</u></b></span><br />
            <span style="font-size: 20px; font-family: Simsun;">第七条：本合同解除的条件：<b><u style="font-size: 20px; font-family: Simsun;">按《合同法》执行。</u></b></span><br />
            <span style="font-size: 20px; font-family: Simsun;">第八条：合同争议的解决方式：本合同在履行过程种发生的争议，由双方当事人协商解决；也可由当地工商管理部门调解；协商或调解不成的，按下例第<b><u style="font-size: 20px; font-family: Simsun;">（一）</u></b>种方式解决。</span><br />
            <span style="font-size: 20px; font-family: Simsun; margin-left: 40px">（一）提交<b><u style="font-size: 20px; font-family: Simsun;">杭州市仲裁部门</u></b>仲裁委员会仲裁</span><br />
            <span style="font-size: 20px; font-family: Simsun; margin-left: 40px">（二）依法向人民法院起诉</span><br />
            <span style="font-size: 20px; font-family: Simsun;">第九条：本合同一式四份，双方各执贰份，传真件加盖公章并签署后有效。</span>
        </div>

        <table id="bottomTab" style="word-wrap: break-word; word-break: break-all;">
            <tr>
                <td style="width: 400px; text-align: center"><b style="font-size: 20px; font-family: Simsun;">供方</b></td>
                <td style="width: 400px; text-align: center"><b style="font-size: 20px; font-family: Simsun;">需方</b></td>
            </tr>
            <tbody>
                <tr>
                    <td style="width: 400px; font-size: 16px; font-family: Simsun;">供方（章）：杭州新世纪混合气体有限公司</td>
                    <td style="width: 400px; font-size: 16px; font-family: Simsun;">需方（章）：<span style="font-size: 16px; font-family: Simsun;" id="CustomerNameB"></span></td>
                </tr>
                <tr>
                    <td style="width: 400px; font-size: 16px; font-family: Simsun;">地址：杭州市余杭区仁和街道东风村</td>
                    <td style="width: 400px; font-size: 16px; font-family: Simsun;">地址：<span style="font-size: 16px; font-family: Simsun;" id="ComAddress"></span></td>
                </tr>
                <tr>
                    <td style="width: 400px; font-size: 16px; font-family: Simsun;">开户行：工商银行杭州市半山支行</td>
                    <td style="width: 400px; font-size: 16px; font-family: Simsun;">开户行：<span style="font-size: 16px; font-family: Simsun;" id="Bank"></span></td>
                </tr>
                <tr>
                    <td style="width: 400px; font-size: 16px; font-family: Simsun;">银行行号：</td>
                    <td style="width: 400px; font-size: 16px; font-family: Simsun;">账号：<span style="font-size: 16px; font-family: 'Times New Roman';" id="BankAccount"></span></td>
                </tr>
                <tr>
                    <td style="width: 400px; font-size: 16px; font-family: 'SimSun','Times New Roman';">账号：1202020019900012618 </td>
                    <td style="width: 400px; font-size: 16px; font-family: Simsun;">税号：<span style="font-size: 16px; font-family: 'Times New Roman';" id="TaxpayerID"></span></td>
                </tr>
                <tr>
                    <td style="width: 400px; font-size: 16px; font-family: 'Simsun','Times New Roman'">电话：0517-88132888</td>
                    <td style="width: 400px; font-size: 16px; font-family: Simsun;">电话：<span style="font-size: 16px; font-family: 'Times New Roman';" id="Phone"></span></td>
                </tr>
                <tr>
                    <td style="width: 400px; font-size: 16px; font-family: 'Simsun','Times New Roman';">传真：0517-86395688</td>
                    <td style="width: 400px; font-size: 16px; font-family: Simsun;">传真：<span style="font-size: 16px; font-family: 'Times New Roman';" id="Fax"></span></td>
                </tr>
                <tr>
                    <td style="width: 400px; font-size: 16px; font-family: Simsun;">签约代理人：<span style="font-size: 16px; font-family: Simsun;" id="SAgent"></span></td>
                    <td style="width: 400px; font-size: 16px; font-family: Simsun;">签约代理人：<span style="font-size: 16px; font-family: Simsun;" id="CAgent"></span></td>
                </tr>
            </tbody>
        </table>

    </div>

</asp:Content>
